package net.isanchez.gwt.client.rpc;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.ServiceDefTarget;

public interface HelloWorldService extends RemoteService {

	public String getHelloMessage(String name);

	/**
	 * The deployment path is defined in web.xml and gwt-rpc-servlet.xml
	 */
	public static final String SERVICE_URI = "service/helloWorldService";

	/**
	 * Utility class for simplifying access to the instance of async service.
	 */
	public static class Util {
		private static HelloWorldServiceAsync instance;

		public static HelloWorldServiceAsync getInstance() {
			if (instance == null) {
				instance = (HelloWorldServiceAsync) GWT
						.create(HelloWorldService.class);
				ServiceDefTarget target = (ServiceDefTarget) instance;
				target.setServiceEntryPoint(GWT.getModuleBaseURL()
						+ SERVICE_URI);
			}
			return instance;
		}
	}
}
